package com.google.code.chaotic;

import java.util.logging.Logger;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public final class EmFactory {

	private static Logger logger = Logger//
			.getLogger(EmFactory.class.getName());

	//

	// private static final EntityManagerFactory instance = Persistence
	// .createEntityManagerFactory("backTierEjbLocal");

	private static EntityManagerFactory instance = null;

	//

	private EmFactory() {
		// new org.eclipse.emf.teneo.eclipselink.EmfSessionCustomizer();
	}

	public static synchronized EntityManagerFactory get() {
		if (instance == null) {
			ClassLoader cl = Thread.currentThread().getContextClassLoader();
			logger.info("Thread.getContextClassLoader() : " + cl);
			logger.info("\".\" of the ClassLoader: " + cl.getResource(".")
					+ "\n");
			instance = Persistence
					.createEntityManagerFactory("backTierLocal");
		}
		return instance;
	}
}